import requests
# 1.指定url
post_url = 'https://fanyi.baidu.com/sug'
# 2.进行UA伪装
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36'}
# 3.post请求参数处理(同get请求一致)
word = input('enter a word:')
date = {'kw':word}
# 4.发起请求
response = requests.post(url=post_url,data=date,headers=headers)
# 5.获取响应数据，json()方法返回一个字典或列表(如果确认响应数据是json类型，才可以使用json(),否则会报错)
dic_obj = response.json()
print(dic_obj)
